package com.map.hashmap;

import java.util.Collection;
import java.util.HashMap;
import java.util.Iterator;
import java.util.Map;
import java.util.Set;

public class CuncurrentModificaionException_1 {
public static void main(String[] args) {
	
	Map<String, Integer> map=new HashMap<String, Integer>();
	map.put("key1", 1);
	map.put("key2", 2);
	map.put("key3", 3);
	Collection c=map.keySet();
	Iterator it=c.iterator();
	while(it.hasNext()){
		System.out.println(it.next());
	}
	for(String key:map.keySet()){
		if(map.get(key)==1){
			map.remove(key);
		}
	}
	System.out.println("successfully removed...");
	Set s=map.keySet();
	Iterator it1=s.iterator();
	while(it1.hasNext()){
		System.out.println(it1.next());
	}
	System.out.println("-------------------------");
	for(String key:map.keySet()){
		System.out.println(key);
	}
}
}
